<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  

  <script type="text/javascript">

    var arr = [
      {name:'a', age:12},
      {name:'b', age:13},
      {name:'c', age:10},
      // {name:'d', age:8},
      // {name:'e', age:22},
      // {name:'f', age:7},
      // {name:'g', age:65},
      // {name:'h', age:33},
      // {name:'i', age:5},
      // {name:'j', age:44},
      // {name:'k', age:6},
    ];
    // 按年龄排序
 // 答案 
    

    for(var i = 0; i < arr.length - 1; i++){
      for(var j = 0; j < arr.length - 1; j++){
        if(arr[j].age > arr[j+1].age){
          var tmp = arr[j];
          arr[j] = arr[j+1];
          arr[j+1] = tmp;
        }
      }
    }

    console.log(arr);


  </script>
</body>
</html>